package com.java.jiuyang.commons.entity.terminal;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thoughtworks.qdox.model.expression.Add;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户表(SysUser)实体类
 *
 * @author makejava
 * @since 2019-05-29 11:19:47
 */
@ApiModel(value = "用户类")
@Data
@Accessors(chain = true)
public class SysUser implements Serializable {
    private static final long serialVersionUID = 957447898656198847L;
    //主键
    @ApiModelProperty(value = "主键Id")
    @Id
    @Null(message = "{add_id}", groups = {Add.class})
   // @NotNull(message = "{modify_id}", groups = {Modify.class})
    private String id;
    //登陆名
    @ApiModelProperty(value = "登陆名")
    @NotBlank(message = "{username_null}")
    @Pattern(regexp = "^(?![0-9]+$)[0-9A-Za-z_-]{4,36}$", message = "{username_rule}")
    private String userName;
    //电子邮箱
    @ApiModelProperty(value = "邮箱")
    @Email(message = "{email_error}")
    private String email;
    //手机
    @ApiModelProperty(value = "手机号码")
    @Pattern(regexp = "^1[3|4|5|7|8][0-9]\\d{8}$", message = "{phone_error}")
    private String phone;
    //是否显示手机号：1=显示；0=不显示
    @ApiModelProperty(value = "是否显示手机号")
    private Object isShow;
    //登陆密码
    @ApiModelProperty(value = "密码")
    @JsonIgnore
    @NotBlank(message = "{password_null}", groups = {Add.class})
    @Pattern(regexp = "^$|[a-zA-Z0-9]{6,20}$", message = "{password_error}")
    private String password;
    //微信用户id
    @ApiModelProperty(value = "微信用户id")
    private String unionid;
    //账号状态：1=正常；2=锁定；3=注销
    @ApiModelProperty(value = "账号状态：1=正常；2=锁定；3=注销")
    private Integer status;
    //只允许通过指定的ip登陆，多个地址用逗号分隔
    @ApiModelProperty(value = "只允许通过指定的ip登陆，多个地址用逗号分隔")
    private String ipAddr;
    //只允许通过指定mac地址登陆，多个地址用逗号分隔
    @ApiModelProperty(value = "只允许通过指定mac地址登陆，多个地址用逗号分隔")
    private String macCode;
    //账号生效时间
    @ApiModelProperty(value = "账号生效时间")
    private Date startTime;
    //账号失效时间
    @ApiModelProperty(value = "账号失效时间")
    private Date endTime;
    //用户姓名
    @ApiModelProperty(value = "用户姓名")
    @Pattern(regexp = "^$|[\\s\\S]{1,20}$", message = "{name_rule}")
    private String name;
    //用户英文名
    @ApiModelProperty(value = "用户英文名")
    @Pattern(regexp = "^$|[a-zA-Z\\s]{1,30}$", message = "{enname_rule}")
    private String enName;
    //用户昵称
    @ApiModelProperty(value = "用户昵称")
    private String nickname;
    //用户名称拼音
    @ApiModelProperty(value = "用户名称拼音")
    private String pinyin;
    //身份证号码
    @ApiModelProperty(value = "身份证号码")
    @Pattern(regexp = "^$|[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)" +
            "\\d{3}[0-9Xx]$", message = "{id_card_no_error}")
    private String idCardNo;
    //生日
    @ApiModelProperty(value = "生日")
    private Date birthday;
    //性别：1=男；2=女
    @ApiModelProperty(value = "性别：1=男；2=女")
    private Integer gender;
    //用户所在行政区域
    @ApiModelProperty(value = "用户所在行政区域")
    private String area;
    //头像链接
    @ApiModelProperty(value = "头像链接")
    private String avatar;
    //备注
    private String remark;
    //用户类型：E=内部员工；O=供应商操作员；S=经销商操作员；L=物流商操作员；M=终端商;A=应用
    @ApiModelProperty(value = "用户类型：E=内部员工；O=供应商操作员；S=经销商操作员；L=物流商操作员；M=终端商;A=应用")
    private String userType;
    //创建人id
    private String crtUser;
    //创建人姓名
    private String crtName;
    //创建时间
    private Date crtTime;
    //最后修改人id
    private String updUser;
    //最后修改人姓名
    private String updName;
    //最后修改时间
    private Date updTime;
    //逻辑删除标识：1=删除；0=未删除
    private int delFlag;
    //预留字段
    private String attr1;
    //预留字段
    private String attr2;
    //预留字段
    private String attr3;

    @Transient
    private List<String> roleIds;
    @Transient
    private List<String> orgIds;

    /**
     * @return com.joyoung.cloud.security.api.vo.user.UserInfo
     * @Description 获取用户基本信息对象，用于前台展示
     * @Date 2019/5/31
     * @Param [user]
     **//*
    public static UserInfo buildUserInfo(SysUser user) {
        if (user == null) {
            return new UserInfo();
        }
        UserInfo userInfo = new UserInfo();
        BeanUtils.copyProperties(user, userInfo);
        return userInfo;
    }

    public static void main(String[] args) {
        System.out.println(JSON.toJSONString(new SysUser(), SerializerFeature.WriteMapNullValue));
    }*/
}